const gulp = require('gulp');
const rollup = require('rollup');
const babel = require('rollup-plugin-babel');

const b_src = 'src';
const b_dist = 'public';

gulp.task('js', function () {
  return rollup.rollup({
    input: './src/js/main.js',
    plugins: [
      babel({
        exclude: 'node_modules/**',
        plugins: ['external-helpers'],
        externalHelpers: true,
        runtimeHelpers: true
      })
    ]
  }).then(bundle => {
    return bundle.write({
      file: './public/js/main.js',
      format: 'iife',
      name: 'main',
      sourcemap: true
    });
  });
});


// DEV
gulp.task('dev', ['js'], function() {
  console.log('[工作中..] 👷 👷');
  gulp.watch(b_src + '/js/*.js', ['js']);
});
